import request from '@/utils/request';
import type { categoryResponseData,attrModelList,attrModel } from './model/attr';
//定义请求的地址
enum API {
    //一级分类的接口地址
    C1 = "/admin/product/getCategory1",
    //二级分类的接口地址
    C2 = "/admin/product/getCategory2/",
    //三级分类的接口地址
    C3 = "/admin/product/getCategory3/",
    //获取某一个三级分类下全部商品属性
    ATTR = "/admin/product/attrInfoList/",
    //添加属性|修改属性
    ADDORUPDATEATTR = '/admin/product/saveAttrInfo',
    //删除属性
    DELETEATTR="/admin/product/deleteAttr/"
}

//一级分类的请求
export const reqC1List = () => request.get<any, categoryResponseData>(API.C1);
//二级分类的请求
export const reqC2List = (category1Id: number | string) => request.get<any, categoryResponseData>(API.C2 + category1Id);
//三级分类的请求
export const reqC3List = (category2Id: number | string) => request.get<any, categoryResponseData>(API.C3 + category2Id);

//获取某一个三级分类下平台属性[属性值]
export const reqAttrList = (category1Id: number | string, category2Id: number | string, category3Id: number | string) => request.get<any,attrModelList>(API.ATTR + `${category1Id}/${category2Id}/${category3Id}`);



//添加或者是修改平台属性的接口 [将来请求体携带的参数需要定义类型 , 服务器返回数据需要定义类型]
export const reqAddOrUpdateAttr = (data: attrModel) => request.post<any,any>(API.ADDORUPDATEATTR, data);

//删除某一个平台属性
export const reqDeleteAttr = (attrId:number)=>request.delete<any,any>(API.DELETEATTR+attrId);